package com.kaili.tms.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.tms.mapper.VehicleRouteMapper;
import com.kaili.tms.pojo.entity.VehicleRouteAdd;
import com.kaili.tms.pojo.entity.VehicleRouteDelete;
import com.kaili.tms.pojo.entity.VehicleRouteQuery;
import com.kaili.tms.pojo.entity.VehicleRouteUpdate;
import com.kaili.tms.pojo.vo.VehicleRouteVO;
import com.kaili.tms.service.VehicleRouteService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class VehicleRouteServiceImpl implements VehicleRouteService {

    @Autowired
    private VehicleRouteMapper vehicleRouteMapper;

    @Override
    public Page<VehicleRouteVO> queryVehicleRoutes(Page<VehicleRouteVO> page, VehicleRouteQuery vehicleRouteQuery) {
        return page.setRecords(vehicleRouteMapper.queryVehicleRoutes(page,vehicleRouteQuery));
    }

    @Override
    public int addVehicleRoute(VehicleRouteAdd vehicleRouteAdd) {
        return vehicleRouteMapper.addVehicleRoute(vehicleRouteAdd);
    }

    @Override
    public String getRouteCode() {
        return vehicleRouteMapper.getRouteCode();
    }

    @Override
    public int addVehicleRouteCars(@Param("routeId") Integer routeId, @Param("carIds") Integer[] carIds) {
        return vehicleRouteMapper.addVehicleRouteCars(routeId, carIds);
    }

    @Override
    public int updateVehicleRoute(VehicleRouteUpdate vehicleRouteUpdate) {
        return vehicleRouteMapper.updateVehicleRoute(vehicleRouteUpdate);
    }

    @Override
    public int deleteVehicleRoute(VehicleRouteDelete vehicleRouteDelete) {
        return vehicleRouteMapper.deleteVehicleRoute(vehicleRouteDelete);
    }

    @Override
    public VehicleRouteVO getVehicleRouteById(@Param("routeId") Integer routeId) {
        return vehicleRouteMapper.getVehicleRouteById(routeId);
    }

    @Override
    public int deleteVehicleRouteCars(@Param("routeId") Integer routeId) {
        return vehicleRouteMapper.deleteVehicleRouteCars(routeId);
    }

}
